﻿package mortal.game.view.market.qiugou
{
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.events.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class MarketQiugouPanel extends GSprite
    {
        private var _boxItem:GRadioButton;
        private var _boxCoin:GRadioButton;
        private var _boxGold:GRadioButton;
        private var _qiugouItem:MktQiugouItem;
        private var _qiugouCoin:MktQiugouCoin;
        private var _qiugouGold:MktQiugouGold;
        private var _searchPanel:MktQiugouRtPanel;

        public function MarketQiugouPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._boxItem = UIFactory.radioButton("求购物品", 25, 63, 85, 28, this);
            this._boxCoin = UIFactory.radioButton("求购金币", 115, 63, 85, 28, this);
            this._boxGold = UIFactory.radioButton("求购钻石", 205, 63, 85, 28, this);
            this._boxItem.groupName = "MarketQiugouRadioGroup";
            this._boxCoin.groupName = "MarketQiugouRadioGroup";
            this._boxGold.groupName = "MarketQiugouRadioGroup";
            this._searchPanel = UICompomentPool.getUICompoment(MktQiugouRtPanel);
            this._searchPanel.createDisposedChildren();
            this._searchPanel.x = 355;
            this._searchPanel.y = 92;
            addChild(this._searchPanel);
            this._boxItem.configEventListener(Event.CHANGE, this.radioBtnChange);
            this._boxCoin.configEventListener(Event.CHANGE, this.radioBtnChange);
            this._boxGold.configEventListener(Event.CHANGE, this.radioBtnChange);
            Dispatcher.addEventListener(EventName.MarketPushSeekItem, this.onPushItem);
            this.onPushItem(null);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._boxItem.dispose(param1);
            this._boxCoin.dispose(param1);
            this._boxGold.dispose(param1);
            this._searchPanel.dispose(param1);
            if (this._qiugouItem)
            {
                this._qiugouItem.dispose(param1);
                this._qiugouItem = null;
            }
            if (this._qiugouCoin)
            {
                this._qiugouCoin.dispose(param1);
                this._qiugouCoin = null;
            }
            if (this._qiugouGold)
            {
                this._qiugouGold.dispose(param1);
                this._qiugouGold = null;
            }
            this._boxItem = null;
            this._boxCoin = null;
            this._boxGold = null;
            this._searchPanel = null;
            return;
        }// end function

        private function onPushItem(event:DataEvent) : void
        {
            this._boxItem.selected = true;
            this.radioBtnChange(null);
            return;
        }// end function

        private function radioBtnChange(event:Event) : void
        {
            if (this._qiugouItem)
            {
                this._qiugouItem.visible = false;
            }
            if (this._qiugouCoin)
            {
                this._qiugouCoin.visible = false;
            }
            if (this._qiugouGold)
            {
                this._qiugouGold.visible = false;
            }
            if (this._boxItem.selected)
            {
                this.qiugouItem.visible = true;
            }
            if (this._boxCoin.selected)
            {
                this.qiugouCoin.visible = true;
            }
            if (this._boxGold.selected)
            {
                this.qiugouGold.visible = true;
            }
            return;
        }// end function

        public function get qiugouCoin() : MktQiugouCoin
        {
            if (this._qiugouCoin == null)
            {
                this._qiugouCoin = UIFactory.getUICompoment(MktQiugouCoin, 10, 92, this) as MktQiugouCoin;
            }
            return this._qiugouCoin;
        }// end function

        public function get qiugouItem() : MktQiugouItem
        {
            if (this._qiugouItem == null)
            {
                this._qiugouItem = UIFactory.getUICompoment(MktQiugouItem, 10, 92, this) as MktQiugouItem;
            }
            return this._qiugouItem;
        }// end function

        public function get qiugouGold() : MktQiugouGold
        {
            if (this._qiugouGold == null)
            {
                this._qiugouGold = UIFactory.getUICompoment(MktQiugouGold, 10, 92, this) as MktQiugouGold;
            }
            return this._qiugouGold;
        }// end function

    }
}
